//
//  averageWidthCollectionViewController.m
//  CJUIKitDemo
//
//  Created by ciyouzen on 8/10/15.
//  Copyright (c) 2015 dvlproad. All rights reserved.
//

#import "TSExtralItemCollectionViewController.h"
#import <CQDemoKit/CQTSContainerViewFactory.h>
#import "TSExtralItemCollectionView.h"

@interface TSExtralItemCollectionViewController () {
    
}
@property (nonatomic, strong) TSExtralItemCollectionView *collectionView;
@end

@implementation TSExtralItemCollectionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"CollectionView Demo";
    
    
    
    // buttonsView
    UIView *buttonsView = [CQTSContainerViewFactory threeButtonsViewAlongAxis:MASAxisTypeVertical title1:@"CJExtralItemSettingNone" actionBlock1:^(UIButton * _Nonnull bButton) {
        [self extralItemSettingNone];
        
    } title2:@"CJExtralItemSettingLeading" actionBlock2:^(UIButton * _Nonnull bButton) {
        [self extralItemSettingLeading];
        
    } title3:@"CJExtralItemSettingTailing" actionBlock3:^(UIButton * _Nonnull bButton) {
        [self extralItemSettingTailing];
    }];
    [self.view addSubview:buttonsView];
    [buttonsView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view).mas_offset(120);
        make.height.mas_equalTo(44*3+10*2);
        make.centerX.mas_equalTo(self.view);
        make.left.mas_equalTo(self.view).mas_offset(20);
    }];
    
    


    
    TSExtralItemCollectionView *collectionView = [[TSExtralItemCollectionView alloc] init];
    collectionView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:collectionView];
    [collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(buttonsView.mas_bottom).mas_offset(10);
        make.left.mas_equalTo(self.view).mas_offset(10);
        make.centerX.mas_equalTo(self.view);
        make.height.mas_equalTo(260);
    }];
    self.collectionView = collectionView;
    
    // 设置
    [collectionView updateExtralItemSetting:CJExtralItemSettingTailing];
    
    self.collectionView.dataModels = [CQTSNetImagesUtil __getTestNetImageDataModelsWithCount:20 randomOrder:NO];
    [self.collectionView reloadData];
}


#pragma mark - SettingEvent
- (void)extralItemSettingNone {
    [self.collectionView updateExtralItemSetting:CJExtralItemSettingNone];
    [self.collectionView reloadData];
}

- (void)extralItemSettingLeading {
    [self.collectionView updateExtralItemSetting: CJExtralItemSettingLeading];
    [self.collectionView reloadData];
}

- (void)extralItemSettingTailing {
    [self.collectionView updateExtralItemSetting: CJExtralItemSettingTailing];
    [self.collectionView reloadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
